#include <iostream>

using namespace std;

class Object {
  int value;
private:
  int private_value;
public:
  int public_value;
protected:
  int protected_value;
public:
  Object() { cout << "Object 无参构造" << endl; }

  Object(int a) { cout << "Object constructor called with value = " << a << endl; }
};

class MyClass : public Object {
  int value;
private:
  int private_value;
protected:
  int protected_value;
public:
  int public_value;
  using Object::Object;

  MyClass() { std::cout << "MyClass 普通构造函数被调用" << std::endl; }

  MyClass(const MyClass &other);

  MyClass(MyClass &&other);

  MyClass(int a, int b);

  // ~MyClass() = default;
  // ~MyClass() { std::cout << "析构函数被调用" << std::endl; }

  explicit MyClass(int x, double b) : value(x) {}

  explicit MyClass(double x) : value(x) {} // 显式转换构造函数

  // MyClass(const MyClass &other) = delete;
  MyClass &operator=(const MyClass &other) = delete;

  // MyClass(MyClass &&other) = default;
  MyClass &operator=(MyClass &&other) = default;

  int operator+(const MyClass &other) const { return 10 + other.value; }

  int operator-(const MyClass &other) const { return 10 - other.value; }

  int operator*(const MyClass &other) const { return 10 - other.value; }

  int operator/(const MyClass &other) const { return 10 - other.value; }

  bool operator==(const MyClass &other) const { return 10 > other.value; }
};

MyClass::MyClass(const MyClass &other) { std::cout << "MyClass 拷贝构造函数被调用" << std::endl; }

MyClass::MyClass(MyClass &&other) { std::cout << "MyClass 移动构造函数被调用" << std::endl; }

MyClass::MyClass(int a, int b) : Object(a) { cout << "MyClass constructor a = " << a << ", b = " << b << endl; }

// class A {
// public:
//   A(int a = 3, double = 2.4) {}
// };
//
// class B : public A {
// public:
//   using A::A;
// };

class A {
public:
  A(int a) {}
};

class B {
public:
  B(int b) {}
};

class C : public A, public B {
public:
  // using A::A;
  // using B::B;
};

class Animal {
public:
  void makeSoundXxx();

  virtual void makeSound() {
    std::cout << "The animal makes a sound" << std::endl;
  }
};

class Dog : public Animal {
public:
  void makeSoundXxx() {
    std::cout << "The dog barks" << std::endl;
  }

  void makeSound() override {
    std::cout << "The dog barks" << std::endl;
  }
};

class Cat : public Animal {
public:
  void makeSoundXxx() {
    std::cout << "The cat meows" << std::endl;
  }

  void makeSound() override {
    std::cout << "The cat meows" << std::endl;
  }
};

int main(int argc, char *argv[]) {
  system("chcp 65001");

  MyClass obj1; // 调用默认构造函数
  // obj1.~MyClass(); // 调用默认析构函数
  // MyClass obj2(obj1); // 调用拷贝构造函数
  // MyClass obj3(std::move(obj1)); // 调用移动构造函数
  // MyClass obj4(10, 20);

  double x = 3.14;
  // MyClass obj5 = x; // 此行会导致编译错误，因为 explicit 关键字禁止了隐式转换
  MyClass obj6(x); // 必须显式地调用构造函数来创建 MyClass 对象

  MyClass obj7(x, 1); // 必须显式地调用构造函数来创建 MyClass 对象

  B b(1);
  // B bb(1, 2.5);
  B bbb(2.5);
  B bbbb();


  Dog *myAnimal = new Dog();
  myAnimal->makeSound(); // 输出：The dog barks
  myAnimal->makeSoundXxx(); // 输出：The dog barks

  Animal *myOtherAnimal = new Cat();
  myOtherAnimal->makeSound(); // 输出：The cat meows
  // myOtherAnimal->makeSoundXxx(); // 输出：The cat meows

  return 0;
}